<div class="home page">
    <?php echo '<b>Welcome ' . $authName.'</b>'; ?>
    <br /><br />
    <div id="unfinished">
        <?php
        echo "Below is a list of unfinished jobs assigned to you";
        $tasks = $this->requestAction('outstanding_tasks/search/' . $authID);
        echo "<br /> <br /> <br />";
        if (!empty($tasks)) {
        ?>
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <th class="title"><?php echo "Task"; ?></th>
                    <th class="actions"><?php __('Actions'); ?></th>
                </tr>
            <?php
            $i = 0;
            foreach ($tasks as $task):
                $class = null;
                if ($i++ % 2 == 0) {
                    $class = ' class="altrow"';
                }
            ?>
                <tr<?php echo $class; ?>>
                    <td><?php echo $task['outstanding_tasks']['tasks']; ?>&nbsp;</td>
                    <td class="actions">
                    <?php echo $this->Html->link(__('Details', true), array('controller' => 'outstanding_tasks', 'action' => 'view/' . $task['outstanding_tasks']['id']), array('title' => 'View task', 'onclick' => "Modalbox.show(this.href, {title: this.title, width: 500}); return false;")); ?>
                    <?php echo $this->Html->link(__('Edit', true), array('controller' => 'outstanding_tasks', 'action' => 'edit/' . $task['outstanding_tasks']['id']), array('title' => 'Edit Task', 'onclick' => "Modalbox.show(this.href, {title: this.title, width: 500}); return false;")); ?>
                    <?php //echo $this->Html->link(__('Delete', true), array('controller' => 'outstanding_tasks', 'action' => 'delete', $task['outstanding_tasks']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $task['outstanding_tasks']['id']));  ?>
                </td>
            </tr>
        </table>
        <?php
                    endforeach;
                } else {
                    echo "<center>No outstanding tasks assigned to you.</center>";
                }
        ?>
            </div>
       <div id="recent">
        <?php
                echo "Below is a list of your most recent timesheets";
                $timesheets = $this->requestAction('timesheets/latestTimesheets/' . $authID);
                echo "<br /> <br /> <br />";
                if (!empty($timesheets)) {
        ?>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th class="title"><?php echo "Customer"; ?></th>
                            <th class="title"><?php echo "Duration"; ?></th>
                            <th class="actions"><?php __('Actions'); ?></th>
                        </tr>
            <?php
                    $i = 0;
                    foreach ($timesheets as $timesheet):
                        $class = null;
                        if ($i++ % 2 == 0) {
                            $class = ' class="altrow"';
                        }
            ?>
                        <tr<?php echo $class; ?>>

                            <td><?php echo $timesheet['timesheets']['customer name']; ?>&nbsp;</td>
                            <td><?php $duration = ($timesheet['timesheets']['finish time'] - $timesheet['timesheets']['start time']);
                        echo $duration; ?>&nbsp;</td>
                    <td class="actions">
                    <?php echo $this->Html->link(__('Details', true), array('controller' => 'timesheets', 'action' => 'view/' . $timesheet['timesheets']['id']), array('title' => 'View timesheet', 'onclick' => "Modalbox.show(this.href, {title: this.title, width: 500}); return false;")); ?>
                    <?php echo $this->Html->link(__('Edit', true), array('controller' => 'timesheets', 'action' => 'edit/' . $timesheet['timesheets']['id']), array('title' => 'Edit timesheet', 'onclick' => "Modalbox.show(this.href, {title: this.title, width: 500}); return false;")); ?>
                    <?php //echo $this->Html->link(__('Delete', true), array('controller' => 'outstanding_tasks', 'action' => 'delete', $task['outstanding_tasks']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $task['outstanding_tasks']['id']));  ?>
                    </td>
                </tr>
            </table>
        <?php
                        endforeach;
                    } else {
                        echo "<center>No recent timesheets.</center>";
                    }
        ?>
    </div>
</div>